package edu.sctu.wangfuxin.day20150615;

import java.io.*;

/**
 * Created by user06 on 2015/6/15.
 */
public class TestObject_IO {
    String file = "D:\\TestIO\\test_Serializable.txt";
    /**
     * 序列化
     * @throws Exception
     */
    public void test_Serializable() throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
        Student student = new Student("聂宇巨狗",1406101055,20);
        oos.writeObject(student);
        oos.flush();
        oos.close();
    }
    /**
     * 反序列化
     */

    public void test_Serializable1() throws Exception{
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
        Student student = (Student)ois.readObject();
        System.out.println(student);
        ois.close();
    }
}
